//
//  Untitled.swift
//  PLDownload
//
//  Created by bin hu on 2025/7/7.
//

import Foundation

class DownloadQueue {
    func startNextTask() {
        guard activeTasks.count < maxConcurrentDownloads,
              let nextTask = waitingQueue.first else { return }
        
        nextTask.state = .downloading
        activeTasks[nextTask.id.uuidString] = nextTask
        waitingQueue.removeFirst()
        
        nextTask.protocolHandler?.startDownload()
    }
}
